using Mapster;
using SmartAgricultureService.Tables;

namespace SmartAgricultureService.Models.Tables
{
    public class ReportDetailInfo
    {
        public int Hour { get; set; }
        public string DeviceId { get; set; }
        public string ReportId { get; set; }
        public decimal MinHumidity { get; set; }
        public decimal MinTemperature { get; set; }
        public decimal MinIllumination { get; set; }
        public decimal MaxHumidity { get; set; }
        public decimal MaxTemperature { get; set; }
        public decimal MaxIllumination { get; set; }
        public decimal AvgHumidity { get; set; }
        public decimal AvgTemperature { get; set; }
        public decimal AvgIllumination { get; set; }
        public string Description { get; set; }
        public string DeviceName { get; set; }
        public static TypeAdapterConfig GetAdapterConfig()
        {
            var config = new TypeAdapterConfig();
            return config.ForType<ReportDetailEntry, ReportDetailInfo>()
                .Map(dest => dest.Hour, src => src.Hour)
                .Map(dest => dest.DeviceId, src => src.DeviceId)
                .Map(dest => dest.ReportId, src => src.ReportId)
                .Map(dest => dest.Description, src => src.Description)
                .Map(dest => dest.MinHumidity, src => src.MinHumidity)
                .Map(dest => dest.MinTemperature, src => src.MinTemperature)
                .Map(dest => dest.MinIllumination, src => src.MinIllumination)
                .Map(dest => dest.MaxHumidity, src => src.MaxHumidity)
                .Map(dest => dest.MaxTemperature, src => src.MaxTemperature)
                .Map(dest => dest.MaxIllumination, src => src.MaxIllumination)
                .Map(dest => dest.AvgHumidity, src => src.AvgHumidity)
                .Map(dest => dest.AvgTemperature, src => src.AvgTemperature)
                .Map(dest => dest.AvgIllumination, src => src.AvgIllumination)
                .Map(dest => dest.DeviceName, src => src.Device.Name, o => o.Device != null)
                .Config;
        }
    }
}